package com.api.shopapi.service.impl;

import com.api.shopapi.entity.ConsultRecord;
import com.api.shopapi.entity.dto.ConsultRecordDTO;
import com.api.shopapi.mapper.ConsultRecordMapper;
import com.api.shopapi.service.ConsultRecordService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("ConsultRecordServiceImplOne")
public class ConsultRecordServiceImpl implements ConsultRecordService {

    @Autowired
    private ConsultRecordMapper consultRecordMapper;

    @Override
    public int insert(ConsultRecord consultRecord) {
        return consultRecordMapper.insert(consultRecord);
    }

    @Override
    public int update(ConsultRecord consultRecord) {
        return consultRecordMapper.update(consultRecord);
    }

    @Override
    public ConsultRecord getByConsultRecordCode(String consultRecordCode) {
        return consultRecordMapper.getByConsultRecordCode(consultRecordCode);
    }

    @Override
    public PageInfo<ConsultRecordDTO> getPageAdm(int pageIndex, int pageSize, int status, String startTime, String endTime,String governmentCode) {
        PageHelper.startPage(pageIndex,pageSize);
        List<ConsultRecordDTO> consultRecordDTOList = consultRecordMapper.getPageAdm(startTime, endTime, status, governmentCode);
        return new PageInfo<>(consultRecordDTOList);
    }

    @Override
    public PageInfo<ConsultRecordDTO> getPageApp(int pageIndex, int pageSize, int status,String userCode) {
        PageHelper.startPage(pageIndex,pageSize);
        List<ConsultRecordDTO> consultRecordDTOList = consultRecordMapper.getPageApp(status,userCode);
        return new PageInfo<>(consultRecordDTOList);
    }
}
